package com.example.feilin.config;

import com.example.feilin.controller.DriverController;
import com.example.feilin.controller.IndexController;
import com.example.feilin.controller.MaterialController;
import com.example.feilin.controller.SysConfigController;
import com.example.feilin.controller.VehicleController;
import com.example.feilin.entity.Driver;
import com.example.feilin.entity.Material;
import com.example.feilin.entity.Queue;
import com.example.feilin.entity.SysConfig;
import com.example.feilin.entity.Vehicle;
import com.jfinal.config.Constants;
import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.jfinal.config.JFinalConfig;
import com.jfinal.config.Plugins;
import com.jfinal.config.Routes;
import com.jfinal.kit.PropKit;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.activerecord.CaseInsensitiveContainerFactory;
import com.jfinal.plugin.activerecord.dialect.OracleDialect;
import com.jfinal.plugin.c3p0.C3p0Plugin;

public class DemoConfig extends JFinalConfig {

	@Override
	public void configConstant(Constants me) {
		// TODO Auto-generated method stub
		PropKit.use("a_litter_config.txt");
		me.setDevMode(PropKit.getBoolean("devMode", false));
	}

	@Override
	public void configRoute(Routes me) {
		// TODO Auto-generated method stub
		me.add("/", IndexController.class, "WEB-INF/pages");
		me.add("/config", SysConfigController.class, "WEB-INF/pages/config");
		me.add("/material", MaterialController.class, "WEB-INF/pages/material");
		me.add("/driver", DriverController.class, "WEB-INF/pages/driver");
		me.add("/vehicle", VehicleController.class, "WEB-INF/pages/vehicle");
	}

	@Override
	public void configPlugin(Plugins me) {
		// TODO Auto-generated method stub
		
		C3p0Plugin c3p0Plugin = new C3p0Plugin(PropKit.get("jdbc.url"),
                PropKit.get("jdbc.user"), PropKit.get("jdbc.password"), PropKit.get("jdbc.driver"));
        me.add(c3p0Plugin);


        ActiveRecordPlugin arp = new ActiveRecordPlugin(c3p0Plugin);
        arp.setDialect(new OracleDialect()); // oracle 方言
        arp.setContainerFactory(new CaseInsensitiveContainerFactory()); //大小写忽略
        me.add(arp);
        
        arp.addMapping("T_CHECKIN_FORM", Queue.class);  
        arp.addMapping("T_CALLNUM_CONFIG", SysConfig.class);
        arp.addMapping("T_MATERIAL_INFO", Material.class);
        arp.addMapping("T_DRIVER_INFO", Driver.class);
        arp.addMapping("T_CARCERTIFICATION_INFO", Vehicle.class);
	}

	@Override
	public void configInterceptor(Interceptors me) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void configHandler(Handlers me) {
		// TODO Auto-generated method stub
		
	}

}
